import std.stdio;

import std.uuid;
import std.datetime;
import std.bitmanip;

void main()
{
    
    UUID uid = getComb();
    string str = uid.toString();
    writeln("0 data : ", uid.data);
    writeln("0 : ", str);
    writeln("uuid length is  : ", str.length);
    foreach(i; 0..99)
    {
        uid = getComb();
        writeln(i+1 ," data : ", uid.data);
        writeln(i+1 ," : ", uid.toString());
    }
}

// 00 00/ 0/0 0/0 0 
// 7, 224, 124, 254, 119, 184, 73, 246, 144, 57, 106, 55, 119, 141, 88, 1
// 7, 224, 124, 254, 120, 204, 71, 233, 190, 251, 62, 194, 146, 97, 121, 243
UUID getComb()
{
    SysTime tm = Clock.currTime();
    ubyte[16] gdata = randomUUID().data;
    ubyte[2] year = nativeToBigEndian(tm.year());
    gdata[0..2] = year[];
    ubyte m = tm.month();
    ubyte ri = tm.day();
    m = cast(ubyte)((m << 4) | ri);
    gdata[2] = m;
    m = tm.hour();
    ri = tm.minute();
    m = cast(ubyte)((m << 4) | ri);
    gdata[3] = m;
    m = tm.second();
    year  = nativeToBigEndian(cast(short)tm.fracSecs().total!("msecs")());
    ri = year[0];
    m = cast(ubyte)((m << 4) | ri );
    gdata[4] = m;
    gdata[5] = year[1];
    
    return UUID(gdata);
}
